Xbasic

FTP_SCRIPT_RUN Function

Syntax

Result as C = FTP_SCRIPT_RUN(C title, C ftp_script [, L background [, N total_bytes]])

Arguments

titleCharacter

The dialog title.

ftp_scriptCharacter

A CR-LF delimited list of ftp commands to execute. See FTP Command Syntax below for more information.

backgroundLogical

If .T., the file transfer takes place in the background. The progress dialog box that is displayed is modeless. If .F., the file transfer takes place in the foreground. The progress dialog box that is displayed is modal.

total_bytesNumeric

The total number of bytes to be transferred by the FTP operation. If this value is specified, then the progress dialog box will display a progress bar.

Returns

ResultCharacter

If background is set to .F., returns "OK", "Cancel" or "Error".

OK

All FTP commands were executed

Cancel

User clicked the Cancel button before all FTP commands had executed

Error

n error was encountered

Description

Run an Alpha Anywhere FTP script. Alpha Anywhere has a simple "FTP language" that can be used to write scripts that execute various FTP commands such as uploading and downloading files, making folders on the remove FTP target, renaming and deleting files and folders, etc. This function executes a FTP script created by FTP_MakeCommandList().

FTP Command Syntax

Command
Description
connect| Address

Connects to an FTP site specified by Address

login| User | Password

Logs in to an FTP site.

list| Optional_Mask

Lists files on a FTP site and places the result in the List_Result variable. The Eval command can use List_Result. To list only files that match a mask, specify the Optional_Mask.

nlist| Optional_Mask

Lists files (filenames only, no additional information) on a FTP site and places the result in the List_Result variable. This variable can be used in the Eval command.

To list only files that match a mask, specify the Optional_Mask.

quit

End the FTP session.

cd| Path

Change the working directory on the FTP site.

binary

Execute this command before transferring a binary file.

ascii

Execute this command before transferring an ASCII file

pwd

Returns the name of the current working directory (i.e. folder) on the FTP site and places it in the Result variable which can be used in an expression with the Eval command

rm| File_Name

Deletes a file on the FTP site

mkdir| Folder_Name

Makes a folder on the FTP site.

rmdir| Folder_Name

Deletes a folder on the FTP site.

rename| Old_File_Name | New_File_Name

Renames a file on the FTP site.

get| Remote_File_Name | Local_File_Name

Transfers a file from the FTP site to the local machine.

put| Local_File_Name | Remote_File_Name

Transfers a file from the local machine to the FTP site.

Advanced FTP Command Syntax

Command
Description
eval| Expression

Evaluates Expression and then executes the resulting command. The eval command, in effect, allows you to dynamically generate FTP commands to be executed. The Expression can reference the following special variables: Result = Result of last FTP command (e.g. error code returned, path returned by PWD command, etc.)

List_Result = List of files returned by LIST or NLIST command.

onerror| Command

If the prior FTP command fails, then the Command specified by onerror is executed.

log| Text

Concatenates text to the status text displayed by the progress dialog box.

error| Text

Reports an error and quits the session.

replace| Searchtext | Replacetext

Modifies the commands that follow in the script. An example of how this might be used is to replace a placeholder in the script with the folder name that is retrieved through the pwd command.

See Also